package com.rht.gulimallcoupon.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rht.gulimallcoupon.entity.CouponSpuCategoryRelationEntity;
import com.rht.gulimallcoupon.service.CouponSpuCategoryRelationService;
import com.rht.common.utils.PageUtils;
import com.rht.common.utils.R;




/**
 * 优惠券分类关联
 *
 * @author rht
 * @email rht@qq.com
 * @date 2024-11-07 13:55:33
 */

@RestController
@RequestMapping("gulimallcoupon/couponspucategoryrelation")
public class CouponSpuCategoryRelationController {
    @Autowired
    private CouponSpuCategoryRelationService couponSpuCategoryRelationService;

    /**
     * 列表
     */
    @Operation(summary ="处理查询全部,分页查询的请求")
    @RequestMapping("/list")
      public R list(@RequestParam Map<String, Object> params){
        PageUtils page = couponSpuCategoryRelationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */

    @Operation(summary ="信息")
    @RequestMapping("/info/{id}")
      public R info(@PathVariable("id") Long id){
		CouponSpuCategoryRelationEntity couponSpuCategoryRelation = couponSpuCategoryRelationService.getById(id);

        return R.ok().put("couponSpuCategoryRelation", couponSpuCategoryRelation);
    }

    /**
     * 保存
     */
    @Operation(summary ="保存")
    @RequestMapping("/save")
     public R save(@RequestBody CouponSpuCategoryRelationEntity couponSpuCategoryRelation){
		couponSpuCategoryRelationService.save(couponSpuCategoryRelation);

        return R.ok();
    }

    /**
     * 修改
     */
    @Operation(summary ="修改")
    @RequestMapping("/update")
     public R update(@RequestBody CouponSpuCategoryRelationEntity couponSpuCategoryRelation){
		couponSpuCategoryRelationService.updateById(couponSpuCategoryRelation);

        return R.ok();
    }

    /**
     * 删除
     */
    @Operation(summary ="删除")
    @RequestMapping("/delete")
      public R delete(@RequestBody Long[] ids){
		couponSpuCategoryRelationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
